package com.twu.biblioteca;

import java.util.HashMap;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: jfarah
 * Date: 10/14/13
 * Time: 11:05 AM
 * To change this template use File | Settings | File Templates.
 */
public class UserInteraction {

    private HashMap<Integer, String> validOptions = new HashMap<Integer, String>();
    private Scanner scanner = new Scanner(System.in);

    public UserInteraction(){
        setValidOptions();
    }

    private void setValidOptions() {
        validOptions.put(0, "Exit");
        validOptions.put(1, "Login");
        validOptions.put(2, "View list of books");
        validOptions.put(3, "View list of movies");
        validOptions.put(4, "Check membership details");
        validOptions.put(5, "Add a new book");
        validOptions.put(6, "Reserve book");
        validOptions.put(7, "Logout");
    }

    public String readFromKeyboard(){
        return scanner.nextLine();
    }

    public int readIntegerFromKeyboard(){
        return scanner.nextInt();
    }

    public HashMap<Integer, String> getValidOptions(){
        return this.validOptions;
    }

    public String printOneOfTheValidOptions(Integer key){
        return key.toString() + " - " + validOptions.get(key) + "\n";
    }

    public String printAllValidOptions(){
        String options = "";
        for (Integer i = 0; i <= validOptions.size()-1; i++)
            options += printOneOfTheValidOptions(i);
        return options;
    }
}
